﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Menus;

namespace ColonisatorGame
{
    /// <summary>
    /// Gestion du chat
    /// </summary>
    public class ChatManager
    {
        public SceneManager sceneManager { get; set; }

        /// <summary>
        /// Définit la zone d'écriture de texte
        /// </summary>
        public Rectangle inputZone { get; set; }
        public bool inputZoneActive { get; set; }
        public bool isWaitingForText { get; set; }
        public bool isWaitingForKeyUpped { get; set; }

        /// <summary>
        /// Définit la zone d'affichage de texte
        /// </summary>
        public Rectangle displayZone { get; set; }
        public bool isMessageDisplaying { get; set; }

        public Dictionary<int, string> listeMessages { get; set; }
        private int currentNoMessage { get; set; }

        public string messageEnCours { get; set; }        

        /// <summary>
        /// Constructeur
        /// </summary>
        /// <param name="scenemgr"></param>
        public ChatManager(SceneManager scenemgr)
        {
            sceneManager = scenemgr;
            listeMessages = new Dictionary<int, string>();
            currentNoMessage = 0;
            messageEnCours = string.Empty;
            inputZoneActive = false;
            isWaitingForText = false;
            isWaitingForKeyUpped = false;
            isMessageDisplaying = false;
        }

        public Color GetInputZoneColor()
        {
            Color returnColor;
            if (inputZoneActive)
            {
                returnColor = Color.Red;
                returnColor.A = 10;
            }
            else
            {
                returnColor = Color.White;
                returnColor.A = 10;
            }
            return returnColor;
        }

        public Color GetDisplayZoneColor()
        {
            Color returnColor;
            returnColor = Color.White;
            returnColor.A = 10;
            return returnColor;
        }

        public void AddCurrentMessageToList()
        {            
            listeMessages.Add(currentNoMessage, messageEnCours);
            messageEnCours = string.Empty;
            isMessageDisplaying = true;
            isWaitingForKeyUpped = false;
            isWaitingForText = false;
            currentNoMessage++;
        }

        public void DisplayMessage(string message)
        {

        }

        public string GetStringFromPressedKey(Keys key)
        {
            KeyEventArgs eventArgs = new KeyEventArgs(key);
            return eventArgs.KeyToString(eventArgs);
        }
    }
}
